<#assign className = table.className>   
<#assign classNameLower = className?uncap_first>   
package ${basepackage}.dao;

import org.springframework.stereotype.Repository;
import javacommon.base.*;
import cn.org.rapid_framework.page.*;
import ${basepackage}.model.*;
import ${basepackage}.vo.query.*;

/**
 * @author Bryan.Zhang@ZOIO.NET
 * @date 1/2/2011
 */

@Repository
public class ${className}Dao extends BaseIbatis3Dao<${className},${table.idColumn.javaType}>{
	
	@Override
	public String getIbatisMapperNamesapce() {
		return "${className}";
	}
	
	public void saveOrUpdate(${className} entity) {
		if(entity.get${table.idColumn.columnName}() == null) 
			save(entity);
		else 
			update(entity);
	}
	
	@SuppressWarnings("unchecked")
	public Page<${className}> findPage(${className}Query query) {
		return pageQuery("${className}.findPage",query);
	}
	
	<#list table.columns as column>
	<#if column.unique && !column.pk>
	public ${className} getBy${column.columnName}(${column.javaType} v) {
		return (${className})getSqlSessionTemplate().selectOne("${className}.getBy${column.columnName}",v);
	}	
	
	</#if>
	</#list>

}
